import { Component } from '@angular/core';
import { NavController, NavParams } from 'ionic-angular';
import { NativeService } from '../../../service/NativeService'
import { HttpService } from '../../../service/httpService';
import { UserService } from '../../../service/userService';
@Component({
  selector: 'page-message',
  templateUrl: 'message.html',
})
export class MessagePage {
  private data:any;
  private showLoading = true;
  constructor(public navCtrl: NavController,
              public nat:NativeService,
              public http:HttpService,
              public user:UserService,
              public navParams: NavParams) {

    this.getData();
  }

  getData(){

    let map = {
      beginTime:this.user.registTime,
      endTime:this.nat.dateFormat(new Date(),'yyyy-MM-dd hh:mm:ss'),
      status:'',
      pageIndex:0,
      pageSize:30
    };
    let url = "/api/User/GetMessageList";
    let self = this;
    this.http.get(url,map,function (res,err) {
      self.showLoading = false;
      if(!err){
        console.log(res);
        self.data = res.list;
      }
    })
  }

  readAction(index){
    let msg = this.data[index];
    let url = '/api/User/ReadMessage';
    let map = {
      Id:msg.Id
    };
    this.http.post(url,map,function (res,err) {
      if(!err){
        console.log(res);
      }
    })

  }


}
